#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <unistd.h>
#include <fcntl.h>
#include <regex.h>
#include "errsys.h"

int main(int argc, char **argv)
{
	regex_t p;
	regmatch_t *pmatch;
	int rerr;
	char *regex="^H.[oi]*X$";
	char buf[4096];
	int i;

	strcpy(buf,"HeooiiX");

	rerr = regcomp(&p, regex, REG_EXTENDED|REG_NEWLINE);
	if(rerr){
		perror("Compiler");
		exit(1);
	}

	pmatch=alloca( sizeof(regmatch_t)*(p.re_nsub+1) );
	rerr=regexec(&p,buf,p.re_nsub+1,pmatch,0);
	if(rerr){
		perror("regexec");
		exit(1);
	}else{
		printf("Regex Matched.\n");
	}

	return 0;
}

